<?php

namespace app\api\extend;

class Openssl
{
    // 加密方式
    const METHOD = 'AES-128-ECB';

    // 密钥
    const PASSWORD = '123456';

    // 选项
    const OPTIONS = 0;

    // 编码
    public static function encode($str) {
        return openssl_encrypt($str, self::METHOD, self::PASSWORD, self::OPTIONS);
    }

    // 解码
    public static function decode($str) {
        return openssl_decrypt($str, self::METHOD, self::PASSWORD, self::OPTIONS);
    }
}